package cn.huaqingcheng.tianshu.security.annotation;

import org.springframework.security.core.annotation.AuthenticationPrincipal;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 当前登录账户 ID {@code Authentication.getPrincipal().getId()}
 *
 * @see <a href="https://docs.spring.io/spring-security/reference/servlet/integrations/mvc.html#mvc-authentication-principal">SpirngMVC 集成 - AuthenticationPrincipal</a>
 */
@SuppressWarnings("SpringElInspection")
@Documented
@Retention(RUNTIME)
@Target(PARAMETER)
@AuthenticationPrincipal(expression = "id")
public @interface CurrentAccountId {
}
